home *** CD-ROM | disk | FTP | other *** search
- Path: access4.digex.net!not-for-mail
- From: ell@access4.digex.net (Ell)
- Newsgroups: comp.lang.c++,comp.lang.c,comp.object,comp.software-eng
- Subject: Re: Pointers are hacks in c++ (portablity hackers etc)
- Followup-To: comp.lang.c++,comp.lang.c,comp.object,comp.software-eng
- Date: 26 Mar 1996 02:31:43 GMT
- Organization: The Universe
- Message-ID: <4j7kuf$2ur@news4.digex.net>
- References: <4ikb6kINN1is@mayne.ugrad.cs.ubc.ca> <DoI5Ao.AyJ@assip.csasyd.oz>
- NNTP-Posting-Host: access4.digex.net
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- jason (jabaker@grail.cba.csuohio.edu) wrote:
- :...
- : I think c++ programmers fear pointers precisely because C++ does
- : nothing to solve the memory management problems of C.
-
- I do not think intermediate and advanced C++ programmers "fear
- pointers". They use them all the time.
-
- : Let's say I've
- : built my list of pointers on the stack using the following macro:
- : #define Stack_new(_T, _ARGS) \
- : (void *_v = alloca(sizeof(_T)), new(_v) _T _ARGS)
- :
- : How should the list cells be destroyed:
-
- Using a macro in this way with C++ is unnecessary in most cases. One
- simply 'news' a cell into existence and if you are using "smart pointers",
- or a single object to register, you can keep track via reference counting.
-
- : [ways to delete and keep track of objects elided]
- : So, there are two questions. How was next allocated -- this can be
- : solved by ensuring that next always comes from the heap.
-
- 'next' should _never_ be a 'local' stack based structure.
-
- : And, does
- : anything else refer to next -- this can't be solved with a reference
- : count, we are dealing with a linked list of arbitrary length, it can
- : only be solved by ensuring that there are no other references.
-
- I don't see how reference counting heap based objects, which register
- themselves in a central place, does not allow effective gc in C++.
-
- Elliott
-